package tomcat;

import tomcat.connector.Request;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

public class Utils {
    public static void sendRequest(String validRequest) {
        Request request = getRequest(validRequest);
        String uri = request.getUri();
        System.out.println(uri);
    }

    public static Request getRequest(String validRequest) {
        InputStream inputStream = new ByteArrayInputStream(validRequest.getBytes());
        Request request = new Request(inputStream);
        request.parse();
        return request;
    }

    public static String readFileToString(String fileName) throws IOException {
        return new String(Files.readAllBytes(Paths.get(fileName)));
    }
}
